<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>6.3.3 组合继承</title>
    <script>
        function SuperType(name) {
            this.name = name;
            this.colors = ['red', 'blue', 'green'];
        }

        SuperType.prototype.sayName = function () {
            console.log('姓名：' + this.name);
        };

        function SubType(name, age) {
            SuperType.call(this, name);
            this.age = age;
        }

        SubType.prototype = new SuperType();
        SubType.prototype.constructor = SubType;
        SubType.prototype.sayAge = function () {
            console.log('年龄：' + this.age);
        };

        let type1 = new SubType('雨夜', 29);
        let type2 = new SubType('花花', 27);
        type1.colors.push('black');
        console.log(type1.colors);
        type1.sayName();
        type1.sayAge();
        console.log('----------------------');
        console.log(type2.colors);
        type2.sayName();
        type2.sayAge();

    </script>
</head>
<body>

</body>
</html>